package com.atguigu;

/**
 * 具体的同事类, 闹钟
 *
 * @author melo
 */
public class Alarm extends Colleague {

    /**
     * 在创建Alarm同事对象时，将自己放入到ConcreteMediator集合中
     *
     * @param mediator 中介者对象
     * @param name     同事具体的名称
     */
    public Alarm(Mediator mediator, String name) {
        super(mediator, name);
        mediator.register(name, this);
    }

    public void sendAlarm(int stateChange) {
        sendMessage(stateChange);
    }

    @Override
    public void sendMessage(int stateChange) {
        // 调用具体中介者对象的getMessage
        this.getMediator().getMessage(stateChange, this.name);
    }

}
